package querysrc;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;

import java.sql.ResultSet;

import com.subway.babynote.syncdata.*;


public class query_food_prop extends query {

	public query_food_prop(sqlConnectionHandler sqlconhandler)
	{
		super(sqlconhandler);
	}	
	
	public List<ClientDataRecordBase> get_food_prop(int ts)
	{

		Connection con = null;	
		ResultSet rs = null;
		querydb qdb = null;
		ArrayList<ClientDataRecordBase> food_props = new ArrayList<ClientDataRecordBase>();
		try
		{
			boolean bret = true;
			con = this.init();	
			if(bret)
			{
				qdb = new querydb(con,sqlscripts.sql_food_prop_sync);		
				bret = qdb.prePS();
			}
			if(bret)
			{
				//qdb.ps.setInt(1, ts);
				rs = qdb.execPSQuery();
				if(rs.next())
				{
					rs.beforeFirst();
					while(rs.next())
					{
						int id = rs.getInt(sqlscripts.sql_food_prop_sync_c1_food_prop_id);
						String pn = rs.getString(sqlscripts.sql_food_prop_sync_c2_food_prop);
						int t = rs.getInt(sqlscripts.sql_food_prop_sync_c3_ts);
						food_props.add(new ClientDataRecord.food_propRecord(id,pn,t));						
					}					
				}
			}			
			return food_props;
		}
		catch(SQLException se) {
		      System.out.println("SQLException: "+se.getMessage());
		      return food_props;
	    }
		catch(Exception e)
		{
			e.printStackTrace();
			return food_props;
		}
		finally
		{
			this.release_resultset(rs);
			this.release_querydb(qdb);
			this.release_connection(con);
			this.finalize();
		}
	}
}
